import asyncio
import redis
from redis import asyncio as aioredis
# 使用 aioredis 创建异步客户端
client = aioredis.from_url("redis://192.168.209.200:6379", db=0)


async def doit():
    try:
        await client.set('名称', '大苹果')
        result = await client.get('名称')
        print(result.decode("utf-8"))
        await client.ping()  # 示例操作：发送 PING 命令
    finally:
        # 确保关闭连接
        await client.aclose()


# 运行异步函数

asyncio.run(doit())